home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / network / exp16116.zip / EXP16MCA.ASM < prev    next >
Assembly Source File  |  1993-07-28  |  3KB  |  163 lines

  1. ;keep these in this order.
  2. pos_reg_2    db    ?
  3. pos_reg_3    db    ?
  4. pos_reg_4    db    ?
  5. pos_reg_5    db    ?
  6.  
  7. write_pos_to_eeprom:
  8. ;the MCA adapter doesn't use softset.  Instead, the driver copies the POS
  9. ;registers to the EEPROM, then life goes on as usual.
  10.     assume    ds:code
  11.     movseg    es,ds
  12.     mov    di,offset pos_reg_2
  13.     mov    dx,102h
  14.     mov    cx,4
  15. wpte_1:
  16.     in    al,dx
  17.     stosb
  18.     inc    dx
  19.     loop    wpte_1
  20.  
  21.     call    disable_slot
  22.  
  23. ; Get the board BASE IO from POS configuration.
  24.  
  25.     mov    bl, 15
  26.     sub    bl, pos_reg_3
  27.     and    bx, 0fh
  28.     shl    bx, 1
  29.     mov    bp, io_addresses[bx]
  30.  
  31. ; The 82586 must be reset to reliably read and write the EEPROM.
  32.     call    reset_586
  33.  
  34. ; First build EEPROM word 0 from POS values into AX.
  35. ; Read EEPROM value, and mask off fields we will modify.
  36.     xor    ax, ax
  37.     call    read_eeprom
  38.     and    ax, 0c20h
  39.  
  40. ; Set BASE I/O value (bits 0 - 3).
  41.     mov    cl, pos_reg_3
  42.     and    cl, 0fh
  43.     or    al, cl
  44.  
  45. ; Set BOOT ROM (FLASH) enable (bit 4).
  46.     mov    cl, pos_reg_2
  47.     shl    cl, 1
  48.     and    cl, 10h
  49.     or    al, cl
  50.  
  51. ; Set BOOT ROM (FLASH) base segment (bits 6 - 9).
  52.     mov    cl, pos_reg_2
  53.     shl    cx, 1
  54.     shl    cx, 1
  55.     and    cx, 03c0h
  56.     or    ax, cx
  57.  
  58. ; Set connection type (AUI/OTHER) bit 12.
  59.     mov    ch, pos_reg_2
  60.     shl    ch, 1
  61.     shl    ch, 1
  62.     and    ch, 10h
  63.     or    ah, ch
  64.  
  65. ; Set IRQ selection (bits 13 - 15).
  66.     mov    ch, pos_reg_3
  67.     shl    ch, 1
  68.     and    ch, 0e0h
  69.     or    ah, ch
  70.  
  71. ; Write new EEPROM word 0.
  72.     mov    bx, ax
  73.     xor    ax, ax
  74.     call    write_eeprom
  75.     jc    copy_pos_to_eeprom_error_j
  76.  
  77. ; Now build EEPROM word 1 from POS values into AX.
  78. ; Read EEPROM value, and mask off fields we will modify.
  79.     mov    ax, 1
  80.     call    read_eeprom
  81.     and    ax, 0ff13h
  82.  
  83. ; Set Memory Base address Adjust value (bits 2 - 3).
  84.     mov    cl, pos_reg_5
  85.     and    cl, 0ch
  86.     or    al, cl
  87.  
  88. ; Set Memory megabyte address selection (bits 5 - 6).
  89.     mov    ch, pos_reg_5
  90.     mov    cl, 5
  91.     shl    ch, cl
  92.     and    ch, 060h
  93.     or    al, ch
  94.  
  95. ; Set auto-connection enable bit (bit 7).
  96.     mov    ch, pos_reg_2
  97.     mov    cl, 6
  98.     shl    ch, cl
  99.     and    ch, 80h
  100.     or    al, ch
  101.  
  102. ; Write new EEPROM word 1.
  103.     mov    bx, ax
  104.     mov    ax, 1
  105.     call    write_eeprom
  106. copy_pos_to_eeprom_error_j:
  107.     jc    copy_pos_to_eeprom_error
  108.  
  109. ; Now build EEPROM word 5 from POS values into AX.
  110. ; Read EEPROM value, and mask off fields we will modify. 
  111.     mov    ax, 5
  112.     call    read_eeprom
  113.     and    ax, 0fff9h
  114.  
  115. ; Now set the Boot ROM selection.
  116.     mov    ch, pos_reg_5
  117.     mov    cl, 3
  118.     shr    ch, cl
  119.     and    ch, 06h
  120.     or    al, ch
  121.  
  122. ; Write new EEPROM word 5.
  123.     mov    bx, ax
  124.     mov    ax, 5
  125.     call    write_eeprom
  126.     jc    copy_pos_to_eeprom_error
  127.  
  128. ; Now build EEPROM word 6 from POS values into AX.
  129. ; Read EEPROM value, and mask off fields we will modify. 
  130.     mov    ax, 6
  131.     call    read_eeprom
  132.     and    ax, 0ff00h
  133.  
  134. ; Set mapping information for segments C and D (bits 0 - 7).
  135.     mov    al, pos_reg_4
  136.  
  137. ; Write new EEPROM word 6.
  138.     mov    bx, ax
  139.     mov    ax, 6
  140.     call    write_eeprom
  141.     jc    copy_pos_to_eeprom_error
  142.  
  143. ; Now recompute EEPROM checksum and save it.
  144. ; First call routine that sums EEPROM values.  We want the sum of all
  145. ; values except the checksum which is the last word in the eeprom.
  146.     mov    cx, 3fh
  147.     call    check_eeprom
  148.  
  149. ; Calculate word value that if summed with what we have will result
  150. ; as 0BABAH.
  151.     mov    ax, 0babah
  152.     sub    ax, bx
  153.  
  154. ; Write new checksum value in AX to the last word in the EEPROM.
  155.     mov    bx, ax
  156.     mov    ax, 3fh
  157.     call    write_eeprom
  158.  
  159. copy_pos_to_eeprom_error:
  160.  
  161.     ret
  162.  
  163.